#ifndef __MyI2C_H
#define __MyI2C_H
#include "stm32f4xx.h"                  // Device header
#include "Delay.h"
#include "stdlib.h"

#if defined IIC_24C02
	#define SCL_Port GPIOB
	#define SCL_Pin GPIO_Pin_8
	#define SDA_Port GPIOB
	#define SDA_Pin GPIO_Pin_9
	#define BUS_CLOCK RCC_AHB1Periph_GPIOB
#elif defined IIC_GT91XX
	#define SCL_Port GPIOB
	#define SCL_Pin GPIO_Pin_0
	#define SDA_Port GPIOF
	#define SDA_Pin GPIO_Pin_11
	#define BUS_CLOCK RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOF
#endif

void I2CInit(void);
void I2CWrite(uint8_t Reg, uint8_t Data);
uint8_t I2CRead(uint8_t Reg);
void I2CWriteLen(uint8_t Reg, uint8_t* Data, int len);
uint8_t* I2CReadLen(uint8_t Reg, int len);

//  All i2c common
void I2CStart(void);
void I2CStop(void);
void I2CSendByte(uint8_t dat);
uint8_t I2C_RecvByte(void);
uint8_t I2CWaitAck(void);
void I2CSendAck(uint8_t opt);

#endif
